package com.gf.framework.demo.excelexportdemo.controller;

import com.gf.framework.demo.excelexportdemo.vo.Student;
import com.gf.framework.web.annotation.ExportExcel;
import com.gf.framework.web.excel.DefaultExportExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author gaofei
 * @date 2022/5/24 18:52
 */
@RestController
@Api("报表导出测试")
public class ExportTestController {
    @GetMapping("studentexport")
    @ExportExcel(exportClass = DefaultExportExcel.class)
    @ApiOperation("报表导出测试")
    public List<Student> getStudents() {
        List<Student> students = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 100; i++) {
            Student student = new Student(
                    i + 1, String.format("姓名%d", i + 1),
                    Math.abs(random.nextInt(60)),
                    LocalDate.of(2020, 1, 1),
                    LocalTime.of(10, 10, 10),
                    LocalDateTime.of(2020, 1, 1, 10, 10, 10));
            students.add(student);
        }
        return  students;
    }

}
